

{template 'common/header'}
<style>
	.navbar-inner tr th{text-align:center;}
	tbody td{text-align: center;}
	tbody td img{width:80px;}
</style>
<div class='container' style='padding:0 5px 10px;margin:0;width:100%'>

<ul class="nav nav-tabs">
  <li {if $op == 'post'}class="active"{/if}><a href="{php echo $this->createWebUrl('test', array('op' => 'post'));}">添加题目</a></li>
  <li {if $op == 'display'}class="active"{/if}><a href="{php echo $this->createWebUrl('test',array('op'=>'display'));}">管理题目</a></li>
 
</ul>
{if $op =='display'}
<div class="panel panel-success">
  <div class="panel-heading">常用工具 > 题目列表</div>
  
</div>

	<form id="form2" class="form-horizontal" method="post">
		<table class="table table-hover">
			<thead class="navbar-inner">
				<tr>
				<th style="width:60px;">全选</th>
					<th style="width:50px;">题号</th>			
          			<th style="width:150px;">问题</th>
          			<th style="width:100px;">A</th>
          			<th style="width:100px;">B</th>
          			<th style="width:100px;">C</th>
          			<th style="width:100px;">D</th>
          			<th style="width:60px;">类型</th>
          			<th style="width:70px;">正确答案</th>
					<th style="min-width:80px;width:80px;">编辑/删除</th>
				</tr>
			</thead>
			<tbody>
				{loop $list $item}
				<td><input type="checkbox" value="{$item['id']}" name="delete[]"></td>
					<td>{$item['qid']}</td>
					<td>{$item['question']}</td>
					<td><?php if($item['type']=="picture"){?><img src="{$_W['attachurl']}{$item['pic_a']}"><?php }else{?>{$item['ans_a']}<?php }?></td>
					<td><?php if($item['type']=="picture"){?><img src="{$_W['attachurl']}{$item['pic_b']}"><?php }else{?>{$item['ans_b']}<?php }?></td>
					<td><?php if($item['type']=="picture"){?><img src="{$_W['attachurl']}{$item['pic_c']}"><?php }else{?>{$item['ans_c']}<?php }?></td>
					<td><?php if($item['type']=="picture"){?><img src="{$_W['attachurl']}{$item['pic_d']}"><?php }else{?>{$item['ans_d']}<?php }?></td>
					<td>{$item['type']}</td>
					<td>{$item['correct_ans']}</td>
					<td>
					<a href="{php echo $this->createWebUrl('test', array('op' => 'post', 'id' => $item['id']))}" title="编辑" class="btn btn-xs btn-primary"><span class="icon icon-compose">编辑</span></a>
					
					<a onclick="if(confirm('此操作不可恢复，确认吗？')){location.href='{php echo $this->createWebUrl('test', array('id' => $item['id'],'op'=>'del'))}'}" href="javascript:;" title="删除" class="btn btn-xs btn-danger"><span class="icon icon-close">删除</span></a>
					</td>				
				</tr>
				
				{/loop}
				<tr >
				<td><input type="checkbox"  onclick="var ck = this.checked;$(':checkbox').each(function(){this.checked = ck});" name=''> <input class="btn btn-primary btn-xs" type="submit" value="删除" name="submit" /></td><td></td><td></td><td></td>
				</tr>
			</tbody>
		</table>
		<input type="hidden" value="test" name="do">
		<input type="hidden" value="del" name="op">
		<input type="hidden" name="token" value="{$_W['token']}" />
		
	</form>
	{$pager}
	
	<script>
		$(function(){
			$('.pagination').removeClass().children().addClass('pagination');
		})
	</script>
	<script>
		$('#form2').submit(function(){
			if($(":checkbox[name='delete[]']:checked").size() > 0){
				return confirm('删除后不可恢复，您确定删除吗？');
			}
			return false;
		}); 
	</script>	
	</div>
		{elseif $op == 'post'}
<div class="panel panel-success">
  <div class="panel-heading">常用工具 > 知识问答 > 添加/修改数据</div>
</div>
<div class="main">
	<form action="" method="post" class="form-horizontal form">
	<div class="panel panel-default">
		<div class="panel-body">
			<div class="form-group">
				<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">问题描述</label>
				<div class="col-sm-10">
					<input type="text" name="question" class="form-control" value="{$item['question']}" />
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">题号</label>
				<div class="col-sm-2">
					<input type="number" name="qid" class="form-control" value="{$item['qid']}" />
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">类型</label>
				<div class="col-sm-10">
					<input name="type" id="text-choice" type="radio" value="text" <?php if($item['type']=="text"){?>checked="checked"<?php }?> checked="checked"/>文字&nbsp;&nbsp;&nbsp;&nbsp;
					<input name="type" id="pic-choice" type="radio" value="picture" <?php if($item['type']=="picture"){?>checked="checked"<?php }?>/> 图片
					<span class="help-block"></span>
				</div>
			</div>
			<div class="type_text">
				<div class="form-group">
					<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">答案A</label>
					<div class="col-sm-10">
						<input type="text" name="ans_a" class="form-control" value="{$item['ans_a']}" />
						<span class="help-block"></span>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">答案B</label>
					<div class="col-sm-10">
						<input type="text" name="ans_b" class="form-control" value="{$item['ans_b']}" /> 
						<span class="help-block"></span>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">答案C</label>
					<div class="col-sm-10">
						<input type="text" name="ans_c" class="form-control" value="{$item['ans_c']}" /> 
						<span class="help-block"></span>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">答案D</label>
					<div class="col-sm-10">
						<input type="text" name="ans_d" class="form-control" value="{$item['ans_d']}" /> 
						<span class="help-block"></span>
					</div>
				</div>
			</div>
			<div class="type_pic">
				<div class="form-group">
					<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">答案A</label>
					<div class="col-sm-6">
						{php echo tpl_form_field_image('pic_a',$item['pic_a']);}
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label"><i style="font-size:12px;font-weight:normal;">图片描述</i></label>
					<div class="col-sm-6">
						<input type="text" name="pic_a_intro" class="form-control" value="{$item['pic_a_intro']}" /> 
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">答案B</label>
					<div class="col-sm-6">
						{php echo tpl_form_field_image('pic_b',$item['pic_b']);}
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label"><i style="font-size:12px;font-weight:normal;">图片描述</i></label>
					<div class="col-sm-6">
						<input type="text" name="pic_b_intro" class="form-control" value="{$item['pic_b_intro']}" /> 
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">答案C</label>
					<div class="col-sm-6">
						{php echo tpl_form_field_image('pic_c',$item['pic_c']);}
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label"><i style="font-size:12px;font-weight:normal;">图片描述</i></label>
					<div class="col-sm-6">
						<input type="text" name="pic_c_intro" class="form-control" value="{$item['pic_c_intro']}" /> 
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">答案D</label>
					<div class="col-sm-6">
						{php echo tpl_form_field_image('pic_d',$item['pic_d']);}
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label"><i style="font-size:12px;font-weight:normal;">图片描述</i></label>
					<div class="col-sm-6">
						<input type="text" name="pic_d_intro" class="form-control" value="{$item['pic_d_intro']}" /> 
					</div>
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">正确答案</label>
				<div class="col-sm-10">
					<select name="correct_ans">
						<option value="{$item['correct_ans']}">{$item['correct_ans']}</option>
						<option value="A">A</option>
						<option value="B">B</option>
						<option value="C">C</option>
						<option value="D">D</option>
					</select>
				</div>
			</div>
			
			<div class="form-group">
				<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label"></label>
				<div class="col-sm-4">
				<input type="hidden" name="id" value="{$item[id]}">
				<input type="hidden" name="token" value="{$_W['token']}" />
					<input name="submit" type="submit" value="提交" class="btn btn-primary span3" />
				</div>
			</div>
			
			</div>
			</div>
	</form>
</div>

{/if}		
</div>
<script>
require(['jquery','util'], function($, util){
	$(function(){
		var editor = util.editor($('#remark')[0]);
 
	});
});
</script>
<script type="text/javascript">
	var ck = this.checked;
	
	$(".type_pic").css("display","none");
	$("#text-choice").click(function(){ 
		if($(this).checked == ck) {
			$(".type_pic").css("display","none");
			$(".type_text").css("display","block");
		}

	});
	$("#pic-choice").click(function(){ 
		if($(this).checked == ck) {
			$(".type_text").css("display","none");
			$(".type_pic").css("display","block");
		}
	});

</script>
{template 'common/footer'}
